﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;

namespace BlueMarble.Genesis.Infrastructure.Behaviors
{
    public class CookieManagerMessageInspectionBehavior : System.ServiceModel.Configuration.BehaviorExtensionElement, System.ServiceModel.Description.IEndpointBehavior
    {
        #region IEndpointBehavior Members

        public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
        { // Ignore
        }

        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            clientRuntime.MessageInspectors.Add(new CookieManagerMessageInspector());
        }

        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        { // Ignore
        }

        public void Validate(ServiceEndpoint endpoint)
        { // Ignore
        }

        #endregion

        public override Type BehaviorType
        {
            get { return typeof(CookieManagerMessageInspectionBehavior); }
        }

        protected override object CreateBehavior()
        {
            return new CookieManagerMessageInspectionBehavior();
        }
    }
}
